package fr.ajicommerce.managedBean;

import java.util.ArrayList;
import java.util.Date;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import fr.ajicommerce.FrontOffice;
import fr.ajicommerce.core.dto.LigneProduitDTO;

@Component("carteDeCreditBean")
@Scope("request")
public class CarteDeCreditBean extends FrontOffice {

	private String nom;
	private String nb_carte;
	private String nb_cryp;
	private Date date;
	private boolean fail;
	private boolean achatReussi;
	
	
	public boolean verificationBank(String nom,String nb_carte,String nb_cryp,Date date)
	{
		
		if((nom.equals("solvable")) || (nom.equals("alexandre")) || (nom.equals("riche")))
			return true;
		
		return false;
		
		
		
	}
	
	public String valider()
	{
		
		
			if (verificationBank(nom, nb_carte, nb_cryp, date))
			{
				
				setAchatReussi(true);
				getPanier().setListeLigneCommande(new ArrayList<LigneProduitDTO>());
				return "/index.xhtml";
			}
			else
			{
				fail = true;
				return null;
			}

		
	}
	
	public CarteDeCreditBean() {
		fail=false;
		setAchatReussi(false);
	}


	public String getNom() {
		return nom;
	}


	public void setNom(String nom) {
		this.nom = nom;
	}


	public String getNb_carte() {
		return nb_carte;
	}


	public void setNb_carte(String nb_carte) {
		this.nb_carte = nb_carte;
	}


	public String getNb_cryp() {
		return nb_cryp;
	}


	public void setNb_cryp(String nb_cryp) {
		this.nb_cryp = nb_cryp;
	}


	public Date getDate() {
		return date;
	}


	public void setDate(Date date) {
		this.date = date;
	}


	public boolean isFail() {
		return fail;
	}


	public void setFail(boolean fail) {
		this.fail = fail;
	}

	public boolean isAchatReussi() {
		return achatReussi;
	}

	public void setAchatReussi(boolean achatReussi) {
		this.achatReussi = achatReussi;
	}


	
	
	
	
}
